package com.koron.operation.classes.info.service.impl;


import com.koron.operation.classes.info.bean.po.ClassesClassifyItem;
import com.koron.operation.classes.info.mapper.ClassesClassifyItemMapper;
import com.koron.operation.classes.info.service.ClassesClassifyItemService;
import org.koron.ebs.mybatis.SessionFactory;
import org.koron.ebs.mybatis.TaskAnnotation;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 班别分类列表(ClassesClassifyItem)表服务实现类
 *
 * @author jzp
 * @since 2023-05-25 10:11:07
 */
@Service
public class ClassesClassifyItemServiceImpl implements ClassesClassifyItemService {

    /**
     * 通过ID查询单条数据
     */
    @Override
    @TaskAnnotation("getById")
    public ClassesClassifyItem getById(SessionFactory factory, String id) {
        ClassesClassifyItemMapper mapper = factory.getMapper(ClassesClassifyItemMapper.class);
        return mapper.selectById(id);
    }

    /**
     * 查询所有数据
     */
    @Override
    @TaskAnnotation("list")
    public List<ClassesClassifyItem> list(SessionFactory factory, ClassesClassifyItem classesClassifyItem) {
        ClassesClassifyItemMapper mapper = factory.getMapper(ClassesClassifyItemMapper.class);
        return mapper.selectList(classesClassifyItem);
    }

    /**
     * 新增数据
     */
    @Override
    @TaskAnnotation("save")
    public boolean save(SessionFactory factory, ClassesClassifyItem classesClassifyItem) {
        ClassesClassifyItemMapper mapper = factory.getMapper(ClassesClassifyItemMapper.class);
        return mapper.insertOrUpdate(classesClassifyItem) > 0;
    }

    @Override
    @TaskAnnotation("saveBatch")
    public boolean saveBatch(SessionFactory factory, List<ClassesClassifyItem> classesClassifyItems) {
        ClassesClassifyItemMapper mapper = factory.getMapper(ClassesClassifyItemMapper.class);
        return mapper.insertOrUpdateBatch(classesClassifyItems) > 0;
    }

    /**
     * 修改数据
     */
    @Override
    @TaskAnnotation("update")
    public boolean update(SessionFactory factory, ClassesClassifyItem classesClassifyItem) {
        ClassesClassifyItemMapper mapper = factory.getMapper(ClassesClassifyItemMapper.class);
        return mapper.update(classesClassifyItem) > 0;
    }

    /**
     * 通过主键删除数据
     */
    @Override
    @TaskAnnotation("deleteById")
    public boolean deleteById(SessionFactory factory, String id) {
        ClassesClassifyItemMapper mapper = factory.getMapper(ClassesClassifyItemMapper.class);
        return mapper.hidden(id) > 0;
    }
}
